# coding: utf8

# html解析库
from bs4 import BeautifulSoup as BS

# html爬虫库
from driver.html_crawler import *

# 配置文件库
from conf import *

def novel_text(next_url):
	url = get_config('dou_luo_da_lu', next_url)
	set_config('dou_luo_da_lu', 'url', url)

	html_bs = BS(get_html(url), 'html.parser')
	text = html_bs.find('div', id='content').text
	print text

	div_bottem = html_bs.find('div', class_='bottem')
	for a in div_bottem.find_all('a'):
		if a.text.strip() == u'上一章':
			set_config('dou_luo_da_lu', 'url_prev', a.get('href'))
		if a.text.strip() == u'下一章':
			set_config('dou_luo_da_lu', 'url_next', a.get('href'))

	bookname = str(html_bs.find('div', class_='bookname').h1)
	print bookname
	set_config('dou_luo_da_lu', 'bookname', bookname)

	return text